//
//  NearListVC.swift
//  pai
//
//  Created by diaojz on 2017/4/13.
//  Copyright © 2017年 SHIELD. All rights reserved.
//

import UIKit
import Hero

private let kCell = "NearListCell"

class NearListVC: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate {

    @IBOutlet weak var collectionView: UICollectionView!

    @IBOutlet weak var publishButton: UIButton!
    // MARK: - LifeCycle
    override func viewDidLoad() {
        super.viewDidLoad()


        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Action
    @IBAction func publishButtonClicked() {
    }

   // MARK: - UICollectionViewDataSource
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 20
    }

    func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 2
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView .dequeueReusableCell(withReuseIdentifier: kCell, for: indexPath) as! NearListCell
        
        cell.heroModifiers = [.fade, .translate(x:100)]
        cell.imageView!.heroID = "image_\(indexPath.item)"
        cell.imageView!.heroModifiers = [.arc]
        cell.isHeroEnabled = true
        
        return cell
    }

    // MARK: -UICollectionViewDelegateFlowLayout
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: kScreenW/2.0, height: 280)
    }
    
    // MARK: -UICollectionViewDelegate
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let vc = UIStoryboard(name: "Publish", bundle: nil).instantiateViewController(withIdentifier: "VideoDetailVC") as! VideoDetailVC
        vc.selectedIndex = indexPath
        navigationController?.pushViewController(vc, animated: true)
    }
}
